﻿
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>权限管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	
	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript">

		$(function(){
			$("#btnSubmit").click(function(){		
			 var  menuList = new Array(); 
			 $("input[type='checkbox']:checked").each(function(){ 
			    menuList.push(this.value);
			 }); 
				
			 $("#menusIdStr").val(menuList.join('_'));		
		 	// alert($("#menusIdStr").val());		
			});
		});

		function checkSubItem(parentId){
		 $("."+parentId).attr("checked",$("#"+parentId).attr("checked"));
		}

		
		function checkParent(parentId){
			$("#"+parentId).removeAttr("checked");		
			 $("."+parentId+":checked").each(function(){
			 	$("#"+parentId).attr("checked","checked");
			 });		
		}
	  	

	</script>
   <link rel="stylesheet" href="../css/style2.css" type="text/css"></link></head>
  
<body class="p10">
  
  
		
   <form action="/shop-admin/RoleServlet?method=update" method="post" >
   		<input type="hidden" id="menusIdStr" name="menusIdStr">
   		<input type="hidden"  name="id" value='1'> <!-- 修改权限信息要用到这个id -->
	
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td height="30">
							<table border="0" cellpadding="0" cellspacing="0" width="100%">
								<tbody>
									<tr>
										<td class="title1" height="24">
											<div class="f_right">
												<span class="White"> 
												<img src="../images/add.gif" height="10"
														width="10"> 
													&nbsp; 
													
	
 &nbsp;&nbsp; &nbsp;</span><span
													class="STYLE1"> &nbsp;</span>
											</div>
											<img src="../images/tb.gif" height="14" width="14"
												class="ico">
											用户权限管理
										</td>
									</tr>
								</tbody>
							</table>
								<div style="margin-top: 8px"></div>
					</td>
				</tr>
				<tr>
    <td>
			 <table class="table1" width="100%" border="0" cellpadding="0" cellspacing="1">
				<tr  class="tr" > 
					<td width="30%"><div align="center" >主模块</div></td><td><div align="center">子模块</div></td>
				</tr>
				
				<tr> 
					<td style="padding-left: 30px" >
						<input id='1' type="checkbox" value='1' onclick='checkSubItem(1)' />
						 权限管理
				    </td>
					<td  style="padding-left: 30px">
						
							<input type="checkbox"  onclick='checkParent(1)'
							class='1' 
							value='6' />用户权限管理
							<br/>
						
					</td>
				</tr>
			    
				<tr> 
					<td style="padding-left: 30px" >
						<input id='2' type="checkbox" value='2' onclick='checkSubItem(2)' />
						 系统管理
				    </td>
					<td  style="padding-left: 30px">
						
							<input type="checkbox"  onclick='checkParent(2)'
							class='2' 
							value='7' />用户添加
							<br/>
						
							<input type="checkbox"  onclick='checkParent(2)'
							class='2' 
							value='8' />用户维护
							<br/>
						
					</td>
				</tr>
			    
				<tr> 
					<td style="padding-left: 30px" >
						<input id='3' type="checkbox" value='3' onclick='checkSubItem(3)' />
						 分类管理
				    </td>
					<td  style="padding-left: 30px">
						
							<input type="checkbox"  onclick='checkParent(3)'
							class='3' 
							value='9' />添加一级分类
							<br/>
						
							<input type="checkbox"  onclick='checkParent(3)'
							class='3' 
							value='10' />添加二级分类
							<br/>
						
							<input type="checkbox"  onclick='checkParent(3)'
							class='3' 
							value='11' />商品分类维护
							<br/>
						
					</td>
				</tr>
			    
				<tr> 
					<td style="padding-left: 30px" >
						<input id='4' type="checkbox" value='4' onclick='checkSubItem(4)' />
						 商品管理
				    </td>
					<td  style="padding-left: 30px">
						
							<input type="checkbox"  onclick='checkParent(4)'
							class='4' 
							value='12' />添加商品
							<br/>
						
							<input type="checkbox"  onclick='checkParent(4)'
							class='4' 
							value='13' />商品维护
							<br/>
						
					</td>
				</tr>
			    
				<tr> 
					<td style="padding-left: 30px" >
						<input id='5' type="checkbox" value='5' onclick='checkSubItem(5)' />
						 会员管理
				    </td>
					<td  style="padding-left: 30px">
						
							<input type="checkbox"  onclick='checkParent(5)'
							class='5' 
							value='14' />会员维护
							<br/>
						
					</td>
				</tr>
			    
				<tr> 
					<td style="padding-left: 30px" >
						<input id='15' type="checkbox" value='15' onclick='checkSubItem(15)' />
						 订单管理
				    </td>
					<td  style="padding-left: 30px">
						
							<input type="checkbox"  onclick='checkParent(15)'
							class='15' 
							value='16' />订单维护
							<br/>
						
					</td>
				</tr>
			    
			</table>		
			<input type="submit" id="btnSubmit" onclick="return confirm('确定提交吗')" value="提交">
			
			<label style="color:red"></label>
  </tr>

</table>




   </form>
   
   
  </body>
  <script type="text/javascript">
	
		//给Array类增加一个 contains 方法
  	   Array.prototype.contains = function (element) {    
			for (var i = 0; i < this.length; i++) {    
					if (this[i] == element) {    
						return true;    
					}    
			}    					
			return false;    
		}   
   
 		 var menuIdStr='1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_17_18_'		 
 		 var  menuIdList = new Array(); 
  	     menuIdList=menuIdStr.split('_');
 		 
		 $("input[type='checkbox']").each(function(){ 
		 	 if(menuIdList.contains(this.value)){
		  		 $(this).attr("checked","checked");  //如果传过来的数组中,包含复选框的value (其值是菜单id),则将其勾选
		  	 }
		 }); 
		
	</script>
</html>